package com.hx.utils;

import java.sql.*;

/**
 * @Auther: QZ
 * @Date: 2022/6/23 - 06 - 23 - {TIME}
 * @version: 1.0
 */
public class SelectTableData {
    public static void selectAllData(Config config,String tablename) throws ClassNotFoundException, SQLException {

        /*String url = config.getUrl();
        String user=config.getUsername();
        String password = config.getPassword();*/
         int id;
         String driverClassName="com.mysql.cj.jdbc.Driver";
         String url="jdbc:mysql://localhost:3306/auto_sql?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC" ;
         String username="root";
         String password="qazwsx";
        Class.forName(driverClassName);
        Connection conn = DriverManager.getConnection(url, username, password);
        Statement st = conn.createStatement();
        String sql = "select * from "+tablename+"";
        //4. 执行sql
        ResultSet re = st.executeQuery(sql);
        //5. 释放资源
        st.close();
        conn.close();
    }
}
